#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time    : 2025/5/12 14:25
@Author  : HZP
@File    : login_schema.py
"""
from flask_wtf import FlaskForm
from marshmallow import Schema, fields
from wtforms.fields.simple import StringField
from wtforms.validators import DataRequired, Email, Length, regexp

from pkg.password import password_pattern


class LoginSchema(FlaskForm):
    email = StringField('email', validators=[
        DataRequired(message='邮箱不能为空'),
        # Email(message='登录邮箱格式错误'),
        Length(min=5, max=254, message="登录邮箱长度在5-254个字符"),
    ])

    password = StringField('password', validators=[
        DataRequired(message='密码不能为空'),
        regexp(regex=password_pattern, message='密码最少包含一个字母，一个数字，并且长度为8-16'),
    ])


class PasswordLoginResp(Schema):
    """账号密码授权认证响应结构"""
    access_token = fields.String()
    expire_at = fields.Integer()
